﻿using System.Windows.Forms;
using System.Collections.Generic;
using System;
namespace Mota.XMLControls
{
    public abstract class GuiSplitter:GuiControl
    {
        private List<GuiControl> _children;

        public GuiSplitter()
        {
            _children = new List<GuiControl>(0);
        }
        public override void Add(GuiControl guiControl)
        {
            _children.Add(guiControl);
        }
        public override System.Collections.IEnumerator GetEnumerator()
        {
            return _children.GetEnumerator();
        }
        public int GetCount()
        {
            return _children.Count;
        }
        public abstract Orientation Orientation{get;set;}
        public override bool Required
        {
            get
            {
                return false;
            }
            set
            {
                //
            }
        }
        public override void SetPropertyValue(String propertyName,String propertyValue)
        {
            base.SetPropertyValue(propertyName, propertyValue);
            switch (propertyName)
            {
                case "Orientation":
                    switch (propertyValue)
                    {
                        case "Horizontal":
                            Orientation = Orientation.Horizontal;
                            break;
                        case "Vertical":
                            Orientation = Orientation.Vertical;
                            break;
                    }
                    break;
            }
        }

        public override void Accept(GuiVisitor visitor)
        {
            visitor.Visit(this);
            foreach (GuiControl child in this)
            {
                child.Accept(visitor);
            }
        }
    }
}
